<template>
  <el-row v-loading="loading">
    <el-col :span="24">
      <el-row class="search-row">
        <el-col :span="12">
          <el-input placeholder="请输入姓名" size="small" v-model="like1" style="width: 260px;">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <div style="height: 30px;">
      </div>
      <el-row>
        <el-col :span="24">
          <el-table :data="findOrder().slice((pageNum-1)*pageSize,pageNum*pageSize)" border size="mini" header-cell-class-name="header-row">
            <el-table-column prop="tjid" label="编号" header-align="center" align="center"></el-table-column>
            <el-table-column prop="jks" label="姓名" header-align="center" align="center"></el-table-column>
            <el-table-column prop="gyfanNum" label="干预方案总量" header-align="center" align="center"></el-table-column>
            <el-table-column prop="gyhfNum" label="干预回访总量" header-align="center" align="center"></el-table-column>
            <el-table-column prop="gyjsNum" label="干预结束总量" header-align="center" align="center"></el-table-column>
          </el-table>
        </el-col>
        <el-col :span="24">
          <el-pagination
            background
            @size-change="handleSizeChange"
            :current-page.sync="pageNum"
            :page-sizes="[2,4,6,8]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="findOrder().length">
          </el-pagination>
        </el-col>
      </el-row>
    </el-col>
  </el-row>
</template>

<script>
import {getAll} from '@/api/xsxgozuoToji'
import {listAllJks} from '@/api/xsxhealthmgr'



export default {
  data() {
      return {
        gzlList:[],
        loading: false,
        like1:'',
        pageSize:4,//每页显示的条数
        pageNum:1,
      };
  },
  methods: {
    handleSizeChange(val) {
     this.pageSize = val;
    },
    async pageInit() {
      try {
        let [sj,jks] = await Promise.all([
          getAll(),
          listAllJks()
        ])
        this.gzlList=sj.data;
        for(let i=0;i<jks.data.length;i++){
          for(let j=0;j<sj.data.length;j++){
            if(jks.data[i].healthMgrId==sj.data[j].jks){
               this.gzlList[j].jks=jks.data[i].healthMgrName;
            }
          }
        }
        console.log(this.gzlList)
      } catch(error) {
        this.outputError(error)
      }
    },
    findOrder(){
        return this.gzlList.filter((item,i)=>{
            if(item.jks.includes(this.like1)){
                return item;
            }
        })
    }
  },
  created() {
    this.pageInit()
  }
}
</script>
